package com.example.javalib.reference;

import java.lang.ref.WeakReference;

public class Weak {
    public static void main(String[] args) {
//        String ss="hello";
        WeakReference weakReference = new WeakReference(new String("hello"));
        System.out.println(weakReference.get());//结果为字符串实例，hello
        System.gc();
        System.out.println(weakReference.get());//回收后，结果为null

    }
}
